<template>
  <span class="list">
    <span class="tip" v-show="tipFlag">{{ tipString }}</span>
    <a href="javascript:;" title="播放列表" class="icon-list" @mouseup.stop="isShow">{{
      le
    }}</a>
  </span>
</template>

<script>
import { useStore } from "vuex";
import bodyMouseup from "@/baseFnMixin/bodyMouseupJudge.js";
import { computed } from "@vue/runtime-core";
export default {
  name: "SongPlayLIstBtn",
  setup() {
    const store = useStore();
    const bodymouseup = bodyMouseup();
    const tipString = computed(() => store.state.SongList.tipString);
    const tipFlag = computed(() => store.state.SongList.tipFlag);
    const le = computed(() =>
      store.state.SongList.songlist !== null ? store.state.SongList.songlist.length : 0
    );

    function isShow() {
      if (!store.state.SongList.flag) {
        // 显示播放列表

        store.commit("SongList/changFlag", true);
        store.commit("PlaySong/changPlayingNumberTimeFlag", true);
        //  开启body的mouseup,鼠标不在floor区域松开时,则播放列表隐藏
        // bodymouseup();
        bodymouseup();
      } else {
        if (!store.state.SongVolume.volumeShow) {
          const body = document.body;
          body.onmouseup = null;
        }

        store.commit("PlaySong/changPlayingNumberTimeFlag", false);
        store.commit("SongList/changFlag", false);
      }
    }

    return {
      isShow,
      le,
      tipFlag,
      tipString,
    };
  },
};
</script>

<style scoped lang="less">
.list {
  float: left;
  position: relative;
  width: 59px;
  height: 36px;
}
.icon-list {
  display: block;
  width: 38px;
  height: 25px;
  margin: 11px 2px 0 0;
  padding: 0 0 0 21px;
  line-height: 27px;
  text-align: center;
  color: #666;
  text-decoration: none;
  background: url("../../../../common/images/playbar.png") no-repeat -42px -68px;
  &:hover {
    background-position: -42px -98px;
  }
}
.tip {
  position: absolute;
  top: -51px;
  left: -65px;
  clear: both;
  width: 152px;
  height: 49px;

  text-align: center;
  color: #fff;
  line-height: 37px;
  background: url("../../../../common/images/playbar.png") no-repeat 0 -287px;
}
</style>
